﻿using System.Collections;

namespace Magic.System;

#region 输入参数
public class MenuInput : BaseSearchInput
{
    /// <summary>
    /// 标题
    /// </summary>
    public virtual string Title { get; set; }
}
/// <summary>
/// 菜单规则新增输入
/// </summary>
public class AddMenuRuleInput
{
    /// <summary>
    /// ID 
    ///</summary>
    public virtual int Id { get; set; }
    /// <summary>
    /// 上级菜单 
    /// 默认值: 0
    ///</summary>
    [Required(ErrorMessage = "上级菜单不能为空")]
    public virtual int Pid { get; set; }
    /// <summary>
    /// 类型:menu_dir=菜单目录,menu=菜单项,button=页面按钮 
    /// 默认值: menu
    ///</summary>
    [Required(ErrorMessage = "目录类型不能为空")]
    public virtual string Type { get; set; }
    /// <summary>
    /// 标题 
    /// 默认值: 
    ///</summary>
    [Required(ErrorMessage = "菜单标题不能为空")]
    public virtual string Title { get; set; }
    /// <summary>
    /// 规则名称 
    /// 默认值: 
    ///</summary>
    [Required(ErrorMessage = "规则名称不能为空")]
    public virtual string Name { get; set; }
    /// <summary>
    /// 路由路径 
    /// 默认值: 
    ///</summary>
    public virtual string Path { get; set; }
    /// <summary>
    /// 图标 
    /// 默认值: 
    ///</summary>
    [Required(ErrorMessage = "图标不能为空")]
    public virtual string Icon { get; set; }
    /// <summary>
    /// 菜单类型:tab=选项卡,link=链接,iframe=Iframe 
    ///</summary>

    public virtual string Menu_type { get; set; }
    /// <summary>
    /// Url 
    /// 默认值: 
    ///</summary>
    public virtual string Url { get; set; }
    /// <summary>
    /// 组件路径 
    /// 默认值: 
    ///</summary>
    public virtual string Component { get; set; }
    /// <summary>
    /// 缓存:0=关闭,1=开启 
    /// 默认值: 0
    ///</summary>
    public virtual byte Keepalive { get; set; }
    /// <summary>
    /// 扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单 
    /// 默认值: none
    ///</summary>
    public virtual string Extend { get; set; }
    /// <summary>
    /// 备注 
    /// 默认值: 
    ///</summary>
    public virtual string Remark { get; set; }
    /// <summary>
    /// 权重(排序) 
    /// 默认值: 0
    ///</summary>
    public virtual int Weigh { get; set; }
    /// <summary>
    /// 状态:0=禁用,1=启用 
    /// 默认值: 1
    ///</summary>
    public virtual string Status { get; set; }
    /// <summary>
    /// 更新时间 
    ///</summary>
    public virtual long? Updatetime { get; set; }
    /// <summary>
    /// 创建时间 
    ///</summary>
    public virtual long? Createtime { get; set; } = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
}
/// <summary>
/// 菜单规则编辑输入
/// </summary>
public class EditMenuRuleInput
{
    /// <summary>
    /// ID 
    ///</summary>
    public virtual int Id { get; set; }
    /// <summary>
    /// 上级菜单 
    /// 默认值: 0
    ///</summary>
    public virtual int? Pid { get; set; }
    /// <summary>
    /// 类型:menu_dir=菜单目录,menu=菜单项,button=页面按钮 
    /// 默认值: menu
    ///</summary>
    public virtual string Type { get; set; }
    /// <summary>
    /// 标题 
    /// 默认值: 
    ///</summary>
    public virtual string Title { get; set; }
    /// <summary>
    /// 规则名称 
    /// 默认值: 
    ///</summary>
    public virtual string Name { get; set; }
    /// <summary>
    /// 路由路径 
    /// 默认值: 
    ///</summary>
    public virtual string Path { get; set; }
    /// <summary>
    /// 图标 
    /// 默认值: 
    ///</summary>
    public virtual string Icon { get; set; }
    /// <summary>
    /// 菜单类型:tab=选项卡,link=链接,iframe=Iframe 
    ///</summary>

    public virtual string Menu_type { get; set; }
    /// <summary>
    /// Url 
    /// 默认值: 
    ///</summary>
    public virtual string Url { get; set; }
    /// <summary>
    /// 组件路径 
    /// 默认值: 
    ///</summary>
    public virtual string Component { get; set; }
    /// <summary>
    /// 缓存:0=关闭,1=开启 
    /// 默认值: 0
    ///</summary>
    public virtual byte Keepalive { get; set; }
    /// <summary>
    /// 扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单 
    /// 默认值: none
    ///</summary>
    public virtual string Extend { get; set; }
    /// <summary>
    /// 备注 
    /// 默认值: 
    ///</summary>
    public virtual string Remark { get; set; }
    /// <summary>
    /// 权重(排序) 
    /// 默认值: 0
    ///</summary>
    public virtual int Weigh { get; set; }
    /// <summary>
    /// 状态:0=禁用,1=启用 
    /// 默认值: 1
    ///</summary>
    public virtual string Status { get; set; }
    /// <summary>
    /// 更新时间 
    ///</summary>
    public virtual long? Updatetime { get; set; } = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
}
/// <summary>
/// 菜单排序输入
/// </summary>
public class SortMenuRuleInput
{
    /// <summary>
    /// 菜单编号Id
    /// </summary>
    [Required(ErrorMessage = "菜单编号Id不能为空")]
    public int Id { get; set; }
    /// <summary>
    /// 目标Id
    /// </summary>
    [Required(ErrorMessage = "目标Id不能为空")]
    public int TargetId { get; set; }
}
#endregion

#region 输出参数
public class MenuOutput : ITreeNode
{
    /// <summary>
    /// 子节点
    /// </summary>
    public List<MenuOutput> Children { get; set; } = new List<MenuOutput>();
    /// <summary>
    /// ID 
    ///</summary>
    public int Id { get; set; }
    /// <summary>
    /// 上级菜单 
    /// 默认值: 0
    ///</summary>
    public int Pid { get; set; }
    /// <summary>
    /// 类型:menu_dir=菜单目录,menu=菜单项,button=页面按钮 
    /// 默认值: menu
    ///</summary>
    public string Type { get; set; }
    /// <summary>
    /// 标题 
    /// 默认值: 
    ///</summary>
    public string Title { get; set; }
    /// <summary>
    /// 规则名称 
    /// 默认值: 
    ///</summary>
    public string Name { get; set; }
    /// <summary>
    /// 路由路径 
    /// 默认值: 
    ///</summary>
    public string Path { get; set; }
    /// <summary>
    /// 图标 
    /// 默认值: 
    ///</summary>
    public string Icon { get; set; }
    /// <summary>
    /// 菜单类型:tab=选项卡,link=链接,iframe=Iframe 
    ///</summary>
    public string Menu_type { get; set; }
    /// <summary>
    /// Url 
    /// 默认值: 
    ///</summary>
    public string Url { get; set; }
    /// <summary>
    /// 组件路径 
    /// 默认值: 
    ///</summary>
    public string Component { get; set; }
    /// <summary>
    /// 缓存:0=关闭,1=开启 
    /// 默认值: 0
    ///</summary>
    //public string Keepalive { get { return this.Name; } set{} }
    public string Keepalive { get; set; }
    /// <summary>
    /// 扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单 
    /// 默认值: none
    ///</summary>
    public string Extend { get; set; }

    /// <summary>
    /// 备注 
    /// 默认值: 
    ///</summary>
    public string Remark { get; set; }
    /// <summary>
    /// 权重(排序) 
    /// 默认值: 0
    ///</summary>
    public int Weigh { get; set; }
    /// <summary>
    /// 状态:0=禁用,1=启用 
    /// 默认值: 1
    ///</summary>
    public string Status { get; set; }

    /// <summary>
    /// 更新时间 
    ///</summary>
    public int? Updatetime { get; set; }

    public long GetId()
    {
        return Id;
    }

    public long GetPid()
    {
        return Pid;
    }

    public void SetChildren(IList children)
    {
        Children = (List<MenuOutput>)children;
    }
} 
#endregion
